#pragma once

#include <linux/rcupdate.h>

struct task_struct;
struct pid;

struct kernel_clone_args
{
	void *stack;
	unsigned long stack_size;
	int (*fn)(void *);
	void *fn_arg;
	const char *name;
	unsigned int flags;
	unsigned int kthread : 1;
	unsigned int idle : 1;
};

extern struct task_struct init_task;

extern void init_idle(struct task_struct *idle, int cpu);

extern int sched_fork(unsigned long clone_flags, struct task_struct *p);
extern int copy_thread(struct task_struct *, const struct kernel_clone_args *);

int kernel_thread_init(struct task_struct *task, void *stack,
					   int (*fn)(void *), void *arg, const char *name,
					   unsigned long flags);

void schedule_tail(struct task_struct *prev);

void put_task_struct(struct task_struct *t);
struct task_struct *get_task_struct(struct task_struct *p);

void __noreturn sched_task_dead(void);

struct task_struct *fork_idle(int);
struct task_struct *copy_process(struct pid *pid, int trace, int node,
				 struct kernel_clone_args *args);
struct task_struct *get_task_struct(struct task_struct *t);
